#! /bin/bash

set -e

pr_info () {
    echo -e "\033[0;32m$*\033[0m"
}

cd_bbb () {
    if [ -z $BBB_WS ]; then
        echo "No env: BBB_WS"
        exit
    fi
    cd $BBB_WS
}


cd_bbb

cd u-boot/

rm -rf output/

#sed '/^CONFIG_DEFAULT_DEVICE_TREE/c\CONFIG_DEFAULT_DEVICE_TREE="am335x-boneblack"' \
    #configs/am335x_evm_defconfig > configs/bbb_defconfig

pr_info "[build] uboot defconfig"
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- am335x_evm_defconfig O=output -j `nproc`

pr_info "[build] uboot"
#make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- DEVICE_TREE=am335x-boneblack O=output -j `nproc`
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-  O=output -j `nproc`
